Ninja Database Pro
IndexExists<T>(String) Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class > IndexExists Method : IndexExists<T>(String) Method
The type of the class
The name of the index, case sensitive
Returns true if the index exists for the passed in type and index name
Syntax
Public Overloads Function IndexExists(Of T As {Class, New})( _
   ByVal indexName As String _
) As Boolean
Dim instance As NinjaDbPro
Dim indexName As String
Dim value As Boolean
 
value = instance.IndexExists(Of T)(indexName)
public bool IndexExists<T>( 
   string indexName
)
where T: class, new()
public:
bool IndexExistsgeneric<typename T>
( 
   String^ indexName
) 
where T: ref class, gcnew()

Parameters

indexName
The name of the index, case sensitive

Type Parameters

T
The type of the class

Return Value

True if it exists
Example
NinjaDbPro db = new NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName");
 
db.OpenDatabase();
 
//Add the index if it doesn't exist
if (!db.IndexExists<Person>("NameIndex"))
{
    db.AddIndex<Person>("NameIndex", "Name", IndexStyle.NonUnique);
}
 
bool indexExists = db.IndexExists<Person>("NameIndex");
 
db.CloseDatabase();
Dim db As New NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName")
db.OpenDatabase()
 
'Add the index if it doesn't exist
If Not db.IndexExists(Of Person)("NameIndex") Then
    db.AddIndex(Of Person)("NameIndex", "Name", IndexStyle.NonUnique)
End If
 
Dim indexExists As Boolean = db.IndexExists(Of Person)("NameIndex")
 
db.CloseDatabase()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

NinjaDbPro Class
NinjaDbPro Members
Overload List